﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Reap.AzureResource.Service {
	using Reap.AzureResource.Data.Infrastructure;
	using Reap.AzureResource.Data.Repositories;
	using Reap.AzureResource.Model.Models;
	using Reap.Common.Runtime.Dependency;

	[Dependency(typeof(ILocationService),ComponentLifeStyle.InRequestScope,Key = "ILocationService")]
	public class LocationService:ILocationService
	{
		private ILocationRepository repository;
		  private IUnitOfWork unitOfWork;
		public LocationService(ILocationRepository repository,IUnitOfWork unitOfWork)
		{
			this.repository = repository;
			this.unitOfWork = unitOfWork;
		}
		public Location AddLocation(Location location)
		{
			repository.Add(location);
			this.SaveChanges();
			return location;
		}

		public Location GetLocationById(int id)
		{
			return repository.GetById(id);
		}
		public void SaveChanges()
		{
			unitOfWork.SaveChanges(); 
		}
	}

	public interface ILocationService {
		Location AddLocation(Location location);
		Location  GetLocationById(int id);
	}
}
